﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ScheduleSystem_Tasks_Calendar : System.Web.UI.Page
{
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        
   
    }


    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void AddEvents(object sender, DayRenderEventArgs e)
    {

        Task MyTask = new Task();
        e.Cell.VerticalAlign = VerticalAlign.Top;


        var role = System.Web.Security.Roles.GetRolesForUser().Single();
        String SqlCommand = "";
        if (User.IsInRole("Administrator"))
            SqlCommand = "select * from task";
        else if (User.IsInRole("Customer"))
            SqlCommand = "select * from task Where CostumerId='" + Membership.GetUser().ProviderUserKey+"'";
        else
            SqlCommand = "select * from task Where UserID='" + Membership.GetUser().ProviderUserKey + "'";
                        







        foreach (System.Data.DataRow row in MyTask.GetTasks(SqlCommand).Rows)
        {
            if (e.Day.Date >= Convert.ToDateTime(row["StartDate"].ToString()) && e.Day.Date <= Convert.ToDateTime(row["DueDate"].ToString()))
            {

                String MyLink = "<p> <a href=UpdateTask.aspx?id=" + row["TaskId"].ToString() + ">" + row["Name"].ToString() + "</a></p>";
                e.Cell.Controls.Add(new LiteralControl(MyLink));
                //HyperLink m = new HyperLink();
                //m.NavigateUrl = "UpdateTask.aspx?TaskId=" + row["TaskId"].ToString();
                //e.Cell.Controls.Add(m);
                //e.Cell.ID = row["TaskId"].ToString();
                e.Cell.BorderColor = System.Drawing.Color.Black;
                e.Cell.BorderWidth = 1;
                e.Cell.BorderStyle = BorderStyle.Solid;
                e.Cell.BackColor = System.Drawing.Color.LightGreen;
                //e.Cell
            }
            
      

        }

    }

    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }

    [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string GetDynamicContent(string contextKey)
    {
        return default(string);
    }
    protected void DueDate_TextChanged(object sender, EventArgs e)
    {

    }
    protected void ButtonYes_Click(object sender, EventArgs e)
    {

        Response.Redirect("UpdateTask.aspx?id='b5e8951a-0f96-4b3c-a6ad-46fbab1c9feb'");
      
    }
}